package com.huabo.system.oracle.mapper;

import com.huabo.system.oracle.entity.TblContractTypeof;
import com.huabo.system.oracle.entity.TblOrganization;
import com.hbfk.util.PageInfo;
import com.huabo.system.service.impl.SysConfig;

import java.math.BigDecimal;

public class TblContractTypeofMapperSqlConfig {
	
	
	public String selectPageInfoList(PageInfo<TblContractTypeof> pageInfo) {
		TblContractTypeof condition = pageInfo.getCondition();
		StringBuffer sqlSb = new StringBuffer("SELECT * FROM (SELECT BUDGET.*,ROWNUM RN FROM (SELECT * from TBL_CONTRACT_TYPEOF WHERE ORGID = "+condition.getOrgId());

		if(condition.getTypeName() != null && !"".equals(condition.getTypeName())) {
			sqlSb.append(" AND TYPENAME LIKE '%"+condition.getTypeName()+"%'");
		}
		if(condition.getTypeId() != null ) {
			sqlSb.append(" AND PARENTID = "+condition.getTypeId()+"");
		}else {
			sqlSb.append(" AND PARENTID IS NULL");
		}
		sqlSb.append(" ORDER BY TYPEID DESC ) BUDGET WHERE rownum <= "+(pageInfo.getCurrentPage()*pageInfo.getPageSize())+" ) WHERE RN > "+pageInfo.getCurrentRecord());
		String sql = sqlSb.toString();
		return sql;
	}
	
	public String selectPageInfoCount(PageInfo<TblContractTypeof> pageInfo) {
		TblContractTypeof condition = pageInfo.getCondition();
		String sqlCount = "SELECT COUNT(*) FROM TBL_CONTRACT_TYPEOF WHERE ORGID = '"+condition.getOrgId()+"'";

		if(condition.getTypeName() != null && !"".equals(condition.getTypeName())) {
			sqlCount += " AND TYPENAME LIKE '%"+condition.getTypeName()+"%'";
		}
		if(condition.getTypeId() != null ) {
			sqlCount += " AND PARENTID = "+condition.getTypeId();
		}else {
			sqlCount += " AND PARENTID IS NULL ";
		}
		return sqlCount;
	}



	

	
}
